﻿/*
 ***************************************************************************
 * Microsoft Visual C# .NET
 * 名称：       App_Input_HappyClubInterestSrhForm
 * 类型：       控制层
 * 功能说明：   快乐管家-兴趣排名检索页面
 * 作者：       章 昕
 * 创建日期：   2007/09/12
 * 修改日期     修改者      修改内容
 * 
 * 
 * ---
 ***************************************************************************
*/
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Shpm.App.Input.Dao;
using Shpm.App.Input.Bean;
using Shpm.App.Commons.Db.Beans.Master;
using Shpm.System;
using log4net;
using Shpm.App.Commons.Utils;

public partial class App_Input_HappyClubInterestSrhForm : System.Web.UI.Page
{
    // log
    protected static ILog log = LogManager.GetLogger(typeof(App_Input_HappyClubInterestSrhForm));

    // page load
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            ViewState["INTEREST_NAME"] = "";
            ViewState["SORT"] = "0";
        }
    }

    // before render
    void Page_PreRender(object sender, EventArgs e)
    {
        HappyClubMemberDao dao = new HappyClubMemberDao();
        HappyClubMemberBean bean = new HappyClubMemberBean();
        bean.InterestName = Convert.ToString(ViewState["INTEREST_NAME"]);
        bean.Sort = Convert.ToString(ViewState["SORT"]);
        IList list = dao.ListInterestStat(bean);
        viewSrhRst.DataSource = list;
        viewSrhRst.DataBind();
    }

    // adjust bind data
    protected void viewSrhRst_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (ViewState["ROW_NO"] == null)
        { ViewState["ROW_NO"] = 1; }
        int index = Convert.ToInt32(ViewState["ROW_NO"]);
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            e.Row.Cells[1].Text = Convert.ToString(index);
            ViewState["ROW_NO"] = ++index;
            ((ImageButton)e.Row.FindControl("ImageButton1"))
                .Attributes.Add("onclick", "openDetail('" + ((HappyClubMemberBean)e.Row.DataItem).InterestDictId + "','" + Server.UrlEncode(((HappyClubMemberBean)e.Row.DataItem).InterestName) + "');return false;");
        }
    }


    // 检索
    protected void btnSearch_Click(object sender, EventArgs e)
    {
        ViewState["INTEREST_NAME"] = txtName.Text;
        ViewState["SORT"] = lstSort.SelectedValue;
        ViewState["ROW_NO"] = 1;
    }
}
